Remove explicit xstrdup(CSTR... in favor of helper.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Sep 2013 17:30:01 +0000 (17:30 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Sep 2013 17:30:01 +0000 (17:30 +0000)
gpsbabel/defs.h
gpsbabel/gpx.cc
gpsbabel/html.cc
gpsbabel/kml.cc
gpsbabel/navicache.cc
gpsbabel/text.cc
gpsbabel/util.cc

index d17311e0e7ecd7e315b8a57237208e6d75b511bb..b72cf1f26ce40211b9cf6478fe6f4c5c38cc032f 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <QtCore/QString>
 #include <QtCore/QDebug>
+#include <QtCore/QTextStream>
 
 # include "src/core/datetime.h"
 
@@ -216,6 +217,7 @@ extern const char gpsbabel_version[];
 extern time_t gpsbabel_now;    /* gpsbabel startup-time; initialized in main.c with time() */
 extern time_t gpsbabel_time;   /* gpsbabel startup-time; initialized in main.c with current_time(), ! ZERO within testo ! */
 extern int geocaches_present;
+extern QTextStream cerr;
 
 #define MILLI_TO_MICRO(t) (t * 1000)  /* Milliseconds to Microseconds */
 #define MICRO_TO_MILLI(t) (t / 1000)  /* Microseconds to Milliseconds*/
@@ -920,6 +922,7 @@ void* xmalloc(size_t size);
 void* xrealloc(void* p, size_t s);
 void xfree(const void* mem);
 char* xstrdup(const char* s);
+char* xstrdup(const QString& s);
 char* xstrndup(const char* s, size_t n);
 char* xstrndupt(const char* s, size_t n);
 char* xstrappend(char* src, const char* addon);
index b0cec01f9e0a1c200499d5d1d3f41ae75e6424e4..b623d25f2f7a0a6a8e24d8bc8734c8d15bc2133a 100644 (file)
@@ -218,7 +218,7 @@ gpx_add_to_global(gpx_global_entry* ge, const QString& s)
 
   gep = (gpx_global_entry*) xcalloc(sizeof(*gep), 1);
   QUEUE_INIT(&gep->queue);
-  gep->tagdata = xstrdup(CSTR(s));
+  gep->tagdata = xstrdup(s);
   ENQUEUE_TAIL(&ge->queue, &gep->queue);
 }
 
@@ -466,10 +466,10 @@ tag_gpx(const QXmlStreamAttributes& attr)
      * version.
      */
     if (! gpx_version) {
-      gpx_version = xstrdup(CSTR(attr.value("version").toString()));
+      gpx_version = xstrdup(attr.value("version").toString());
     } else if ((strtod(gpx_version, NULL) * 10) < (attr.value("version").toString().toDouble() * 10)) {
       xfree(gpx_version);
-      gpx_version = xstrdup(CSTR(attr.value("version").toString()));
+      gpx_version = xstrdup(attr.value("version").toString());
     }
   }
   /* save namespace declarations in case we pass through elements
@@ -557,9 +557,9 @@ start_something_else(const QString el, const QXmlStreamAttributes& attr)
   new_tag->attributes = (char**)xcalloc(sizeof(char*),2*attr_count+1);
   avcp = new_tag->attributes;
   for (int i = 0; i < attr_count; i++)  {
-    *avcp = xstrdup(CSTR(attr[i].name().toString()));
+    *avcp = xstrdup(attr[i].name().toString());
     avcp++;
-    *avcp = xstrdup(CSTR(attr[i].value().toString()));
+    *avcp = xstrdup(attr[i].value().toString());
     avcp++;
   }
   *avcp = NULL; // this indicates the end of the attribute name value pairs.
@@ -936,7 +936,7 @@ gpx_end(const QString& el)
     if (wpt_tmp->notes != NULL) {
       xfree(wpt_tmp->notes);
     }
-    wpt_tmp->notes = xstrdup(CSTR(cdatastr));
+    wpt_tmp->notes = xstrdup(cdatastr);
     break;
   case tt_cache_container:
     waypt_alloc_gc_data(wpt_tmp)->container = gs_mkcont(cdatastr);
@@ -1024,7 +1024,7 @@ gpx_end(const QString& el)
      * Route-specific tags.
      */
   case tt_rte_name:
-    rte_head->rte_name = xstrdup(CSTR(cdatastr));
+    rte_head->rte_name = xstrdup(cdatastr);
     break;
   case tt_rte:
     break;
@@ -1040,7 +1040,7 @@ gpx_end(const QString& el)
     wpt_tmp = NULL;
     break;
   case tt_rte_desc:
-    rte_head->rte_desc = xstrdup(CSTR(cdatastr));
+    rte_head->rte_desc = xstrdup(cdatastr);
     break;
   case tt_rte_number:
     rte_head->rte_num = cdatastr.toInt();
@@ -1049,7 +1049,7 @@ gpx_end(const QString& el)
      * Track-specific tags.
      */
   case tt_trk_name:
-    trk_head->rte_name = xstrdup(CSTR(cdatastr));
+    trk_head->rte_name = xstrdup(cdatastr);
     break;
   case tt_trk:
     break;
@@ -1068,7 +1068,7 @@ gpx_end(const QString& el)
     wpt_tmp = NULL;
     break;
   case tt_trk_desc:
-    trk_head->rte_desc = xstrdup(CSTR(cdatastr));
+    trk_head->rte_desc = xstrdup(cdatastr);
     break;
   case tt_trk_number:
     trk_head->rte_num = cdatastr.toInt();
@@ -1097,7 +1097,7 @@ gpx_end(const QString& el)
   case tt_wpt_name:
   case tt_rte_rtept_name:
   case tt_trk_trkseg_trkpt_name:
-    wpt_tmp->shortname = xstrdup(CSTR(cdatastr));
+    wpt_tmp->shortname = xstrdup(cdatastr);
     break;
   case tt_wpt_sym:
   case tt_rte_rtept_sym:
@@ -1112,7 +1112,7 @@ gpx_end(const QString& el)
   case tt_wpt_cmt:
   case tt_rte_rtept_cmt:
   case tt_trk_trkseg_trkpt_cmt:
-    wpt_tmp->description = xstrdup(CSTR(cdatastr));
+    wpt_tmp->description = xstrdup(cdatastr);
     break;
   case tt_wpt_desc:
   case tt_trk_trkseg_trkpt_desc:
@@ -1120,7 +1120,7 @@ gpx_end(const QString& el)
     if (wpt_tmp->notes != NULL) {
       xfree(wpt_tmp->notes);
     }
-    wpt_tmp->notes = xstrdup(CSTR(cdatastr));
+    wpt_tmp->notes = xstrdup(cdatastr);
     break;
   case tt_pdop:
     wpt_tmp->pdop = cdatastr.toDouble();
index 89fa613b68f5a9ccd6b12951d42b81e099541c8a..652052847f764b12febfbe4b83de1d5a35ecb0c5 100644 (file)
@@ -223,7 +223,7 @@ html_disp(const waypoint* wpt)
         if (html_encrypt && encoded) {
           s = rot13(logpart->cdata);
         } else {
-          s = xstrdup(CSTR(logpart->cdata));
+          s = xstrdup(logpart->cdata);
         }
 
         t = html_entitize(s);
index a2f2e3e9c2895d1bccaa46c567df76858a630aa1..baecac255db4e4a6d3b8a7532dae147578df55fd 100644 (file)
@@ -1358,7 +1358,7 @@ QString kml_geocache_get_logs(const waypoint* wpt)
       if (html_encrypt && encoded) {
         s = rot13(logpart->cdata);
       } else {
-        s = xstrdup(CSTR(logpart->cdata));
+        s = xstrdup(logpart->cdata);
       }
 
       r = r + "<br />";
index 0588e88b3e74caab0875c6ac180f95f8a03b2fbb..04d464ba94657b6a61b9a8a16b24b8b443502752 100644 (file)
@@ -106,13 +106,13 @@ NaviReadCache(const QXmlStreamReader& reader)
   if (a.hasAttribute("cache_id")) {
     int n = a.value("cache_id").toString().toInt();
     QString fn = QString("N%1").arg(n, 5, 16, QChar('0'));
-    wpt_tmp->shortname = xstrdup(CSTR(fn));
+    wpt_tmp->shortname = xstrdup(fn);
 
     UrlLink l(QString(NC_URL) + QString::number(n));
     wpt_tmp->AddUrlLink(l);
   }
   if (a.hasAttribute("name")) {
-    wpt_tmp->description = xstrdup(CSTR(a.value("name").toString()));
+    wpt_tmp->description = xstrdup(a.value("name").toString());
   }
   if (a.hasAttribute("user_name")) {
     gc_data->placer = a.value("user_name").toString();
index 69e3e2a90fe8746ea3ee673ac1567c29872d783b..8e012eca389a15f3bb65700eb81c0c871bec9550 100644 (file)
@@ -232,7 +232,7 @@ text_disp(const waypoint* wpt)
         if (txt_encrypt && encoded) {
           s = rot13(logpart->cdata);
         } else {
-          s = xstrdup(CSTR(logpart->cdata));
+          s = xstrdup(logpart->cdata);
         }
 
         gbfprintf(file_out, "%s", s);
index 66583a43829f63d3204045399347843a705fd0e9..581a8704e1e68f02e55e08fe9c6d6168e1001f0f 100644 (file)
@@ -149,6 +149,11 @@ xstrdup(const char* s)
   return o;
 }
 
+char* xstrdup(const QString& s)
+{
+  return xstrdup(CSTR(s));
+}
+
 /*
  * Duplicate at most sz bytes in str.
  */
@@ -1523,14 +1528,14 @@ strip_html(const utf_string* in)
   char tag[8];
   unsigned short int taglen = 0;
 
-  incopy = instr = xstrdup(CSTR(in->utfstring));
+  incopy = instr = xstrdup(in->utfstring);
   if (!in->is_html) {
     return instr;
   }
   /*
    * We only shorten, so just dupe the input buf for space.
    */
-  outstring = out = xstrdup(CSTR(in->utfstring));
+  outstring = out = xstrdup(in->utfstring);
 
   tag[0] = 0;
   while (*instr) {